<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="listQuery.name" placeholder="name" style="width: 200px;" class="filter-item" />
      <el-input v-model="listQuery.uid" placeholder="uid" style="width: 200px;" class="filter-item" />
      <el-select v-model="timeOrder" placeholder="时间排序方式">
        <el-option v-for="item in timeOrders" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
      <el-date-picker v-model="date1" type="datetime" align="right" placeholder="Please pick a date" />
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
        Search
      </el-button>
    </div>
    <!-- 挖宝 -->
    <el-table :data="wabaoList" border>
      <el-table-column align="center" label="挖宝" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="物品id" width="110" align="center">
        <template slot-scope="scope">{{ scope.row.goodsTid }}</template>
      </el-table-column>
      <el-table-column label="获得的物品列表" width="280" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.res) }}</template>
      </el-table-column>
      <el-table-column label="属性变化">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.uProp) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 攻击 -->
    <el-table :data="fireList" border>
      <el-table-column align="center" label="攻击" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="tuid" width="220" align="center">
        <template slot-scope="scope">{{ scope.row.tuid }}</template>
      </el-table-column>
      <el-table-column label="被攻击的名称" width="120" align="center">
        <template slot-scope="scope">{{ scope.row.tname }}</template>
      </el-table-column>
      <el-table-column label="tRobot" width="70" align="center">
        <template slot-scope="scope">{{ scope.row.tRobot }}</template>
      </el-table-column>
      <el-table-column label="res">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.res) }}</template>
      </el-table-column>
      <el-table-column label="属性变化">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.uProp) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 被攻击 -->
    <el-table :data="befireList" border>
      <el-table-column align="center" label="被攻击" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="fromUid" width="220" align="center">
        <template slot-scope="scope">{{ scope.row.fromUid }}</template>
      </el-table-column>
      <el-table-column label="pos">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.pos) }}</template>
      </el-table-column>
      <el-table-column label="gids">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.gids) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 偷盗 -->
    <el-table :data="theftList" border>
      <el-table-column align="center" label="偷盗" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="tuid" width="220" align="center">
        <template slot-scope="scope">{{ scope.row.tuid }}</template>
      </el-table-column>
      <el-table-column label="被偷的名称" width="120" align="center">
        <template slot-scope="scope">{{ scope.row.tname }}</template>
      </el-table-column>
      <el-table-column label="tRobot" width="70" align="center">
        <template slot-scope="scope">{{ scope.row.tRobot }}</template>
      </el-table-column>
      <el-table-column label="num" width="70" align="center">
        <template slot-scope="scope">{{ scope.row.num }}</template>
      </el-table-column>
      <el-table-column label="goods" width="200" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.goods) }}</template>
      </el-table-column>
      <el-table-column label="res" width="200" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.res) }}</template>
      </el-table-column>
      <el-table-column label="属性变化">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.uProp) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 被偷 -->
    <el-table :data="betheftList" border>
      <el-table-column align="center" label="被偷" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="uid" width="220" align="center">
        <template slot-scope="scope">{{ scope.row.uid }}</template>
      </el-table-column>
      <el-table-column label="名称" width="120" align="center">
        <template slot-scope="scope">{{ scope.row.name }}</template>
      </el-table-column>
      <el-table-column label="fromUid" width="220" align="center">
        <template slot-scope="scope">{{ scope.row.fromUid }}</template>
      </el-table-column>
      <el-table-column label="金币" align="center">
        <template slot-scope="scope">{{ scope.row.gold }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 老虎机 -->
    <el-table :data="slotList" border>
      <el-table-column align="center" label="老虎机" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="老虎机key" width="90" align="center">
        <template slot-scope="scope">{{ scope.row.key }}</template>
      </el-table-column>
      <el-table-column label="倍数" width="80" align="center">
        <template slot-scope="scope">{{ scope.row.spin }}</template>
      </el-table-column>
      <el-table-column label="获得的物品列表" width="200" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.res) }}</template>
      </el-table-column>
      <el-table-column label="属性变化">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.uProp) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 商城 -->
    <el-table :data="shopList" border>
      <el-table-column align="center" label="商城" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="商品信息" width="220" align="center">
        <template slot-scope="scope">{{ scope.row.item }}</template>
      </el-table-column>
      <el-table-column label="获得的物品列表" width="220" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.res) }}</template>
      </el-table-column>
      <el-table-column label="第一次购买赠送" width="110" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.fres) }}</template>
      </el-table-column>
      <el-table-column label="宝箱内的物品" width="200" align="center">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.boxRes) }}</template>
      </el-table-column>
      <el-table-column label="属性变化">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.uProp) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 神秘商店 -->
    <el-table :data="hideShopList" border>
      <el-table-column align="center" label="神秘商店" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="gid" width="110" align="center">
        <template slot-scope="scope">{{ scope.row.gid }}</template>
      </el-table-column>
      <el-table-column label="属性变化">
        <template slot-scope="scope">{{ jsonObjToStr(scope.row.uProp) }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 用户日常 -->
    <el-table :data="userDailyList" border>
      <el-table-column align="center" label="用户日常" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="登录时间" align="center">
        <template slot-scope="scope">{{ scope.row.loginTime | formatDate }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 用户金币 -->
    <el-table :data="userGoldList" border>
      <el-table-column align="center" label="用户金币" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="金币来源" align="center">
        <template slot-scope="scope">{{ scope.row.from }}</template>
      </el-table-column>
      <el-table-column label="新金币值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.newVal }}</template>
      </el-table-column>
      <el-table-column label="旧金币值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.oldVal }}</template>
      </el-table-column>
      <el-table-column label="金币差值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.val }}</template>
      </el-table-column>
      <el-table-column label="获取时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 用户体力 -->
    <el-table :data="userEnergyList" border>
      <el-table-column align="center" label="用户体力" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="体力来源" align="center">
        <template slot-scope="scope">{{ scope.row.from }}</template>
      </el-table-column>
      <el-table-column label="新体力值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.newVal }}</template>
      </el-table-column>
      <el-table-column label="旧体力值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.oldVal }}</template>
      </el-table-column>
      <el-table-column label="体力差值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.val }}</template>
      </el-table-column>
      <el-table-column label="获取时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 用户地址 -->
    <el-table :data="userAddrList" border>
      <el-table-column align="center" label="用户地址" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="地址端口" align="center">
        <template slot-scope="scope">{{ scope.row.addr }}</template>
      </el-table-column>
      <el-table-column label="时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>
    <!-- 用户钻石 -->
    <el-table :data="userDiamonList" border>
      <el-table-column align="center" label="用户钻石" width="100">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column label="钻石来源" align="center">
        <template slot-scope="scope">{{ scope.row.from }}</template>
      </el-table-column>
      <el-table-column label="新钻石值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.newVal }}</template>
      </el-table-column>
      <el-table-column label="旧钻石值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.oldVal }}</template>
      </el-table-column>
      <el-table-column label="钻石差值" width="200" align="center">
        <template slot-scope="scope">{{ scope.row.val }}</template>
      </el-table-column>
      <el-table-column label="获取时间" width="160" align="center">
        <template slot-scope="scope">{{ scope.row.time | formatDate }}</template>
      </el-table-column>
    </el-table>

    <!-- <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageNum" @pagination="fetchData" /> -->
  </div>
</template>

<script>
import { formatDate } from '@/utils/date'
import { fireList, wabaoList, befireList, theftList, betheftList, shopList, slotList, hideShopList, userDailyList, userAddrList, userGoldList, userEnergyList, userDiamonList } from '@/api/loglist'
import waves from '@/directive/waves' // waves directive
// import Pagination from '@/components/Pagination' // secondary package based on

export default {
  // components: { Pagination },
  directives: { waves },
  filters: {
    formatDate(time) {
      var date = new Date(time * 1000)
      return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
    }
  },
  data() {
    return {
      timeOrders: [
        {
          value: 1,
          label: '按时间顺序'
        }, {
          value: 2,
          label: '按时间倒序'
        }
      ],
      date1: null,
      befireList: null,
      befireTotal: 0,
      betheftList: null,
      betheftTotal: 0,
      fireList: null,
      fireTotal: 0,
      hideShopList: null,
      hideShopTotal: 0,
      shopList: null,
      shopTotal: 0,
      slotList: null,
      slotTotal: 0,
      theftList: null,
      theftTotal: 0,
      userAddrList: null,
      userAddrTotal: 0,
      userDailyList: null,
      userDailyTotal: 0,
      userDiamonList: null,
      userDiamonTotal: 0,
      userEnergyList: null,
      userEnergyTotal: 0,
      userGoldList: null,
      userGoldTotal: 0,
      wabaoList: null,
      wabaoTotal: 0,
      timeOrder: 2,
      listQuery: {
        page: 1,
        pageNum: 20,
        uid: '',
        name: '',
        timeOrder: 2,
        startTime: 0,
        endTime: 0
      }
    }
  },
  created() {
    // this.fetchData()
  },
  methods: {
    fetchData() {
      fireList(this.listQuery).then(response => {
        this.fireTotal = response.data.count
        this.fireList = response.data.logList
      })
      wabaoList(this.listQuery).then(response => {
        this.wabaoTotal = response.data.count
        this.wabaoList = response.data.logList
      })
      befireList(this.listQuery).then(response => {
        this.befireTotal = response.data.count
        this.befireList = response.data.logList
      })
      theftList(this.listQuery).then(response => {
        this.theftTotal = response.data.count
        this.theftList = response.data.logList
      })
      betheftList(this.listQuery).then(response => {
        this.betheftTotal = response.data.count
        this.betheftList = response.data.logList
      })
      shopList(this.listQuery).then(response => {
        this.shopTotal = response.data.count
        this.shopList = response.data.logList
      })
      slotList(this.listQuery).then(response => {
        this.slotTotal = response.data.count
        this.slotList = response.data.logList
      })
      hideShopList(this.listQuery).then(response => {
        this.hideShopTotal = response.data.count
        this.hideShopList = response.data.logList
      })
      userDailyList(this.listQuery).then(response => {
        this.userDailyTotal = response.data.count
        this.userDailyList = response.data.logList
      })
      userAddrList(this.listQuery).then(response => {
        this.userAddrTotal = response.data.count
        this.userAddrList = response.data.logList
      })
      userGoldList(this.listQuery).then(response => {
        this.userGoldTotal = response.data.count
        this.userGoldList = response.data.logList
      })
      userEnergyList(this.listQuery).then(response => {
        this.userEnergyTotal = response.data.count
        this.userEnergyList = response.data.logList
      })
      userDiamonList(this.listQuery).then(response => {
        this.userDiamonTotal = response.data.count
        this.userDiamonList = response.data.logList
      })
    },
    handleFilter() {
      if (this.listQuery.uid === '' && this.listQuery.name === '') {
        this.$message({
          message: 'uid或名称不能同时为空',
          type: 'error'
        })
        return
      }
      if (this.date1 == null) {
        this.$message({
          message: '时间不能为空',
          type: 'error'
        })
        return
      }
      this.listQuery.page = 1
      this.listQuery.timeOrder = this.timeOrder
      this.listQuery.startTime = Date.parse(this.date1.toDateString()) / 1000
      this.listQuery.endTime = this.listQuery.startTime + 23 * 60 * 60
      this.fetchData()
    },
    handleView(row) {

    },
    jsonObjToStr(obj) {
      if (obj === []) {
        return '[]'
      }
      if (obj == null) {
        return 'null'
      }
      return JSON.stringify(obj)
    }
  }
}
</script>
